A microcontroller is a processor on a microchip that, for example, performs arithmetic/logic operations and communicates with other microcontrollers and processors. A microcontroller is a type of microprocessor. A microcontroller creates a software task to perform a set of instructions. The software task is a self-contained set of program instructions that perform a desired set of operations and functions. For example, a task may perform processing on a packet, which is a unit of data. An instruction is a programming command to direct the microcontroller to perform a single operation. Instructions perform operations on data and registers such as MOVE, LOAD, STORE and CLEAR.
To perform processing on a unit of data, the microcontroller may use an external resource. A resource is external if the resource is mapped into the microcontroller's memory map. A resource is direct if the microcontroller has direct access to the resource, i.e., the resource is not mapped into the microcontroller's memory map. A resource is internal if the resource resides within the microcontroller.
Resources may not always be accessible and ready to use by the microcontroller, for example, if the resource is a shared resource and is currently being used by a different task on the microcontroller or by a different microcontroller. Additionally, resources may be delayed in responding and therefore will not be able to respond within one or two instruction cycles of the microcontroller.
A task running on the microcontroller may execute an instruction that issues a resource request. A resource responds with either a “busy” or a “ready” indication.
If the resource response indicates “busy”, the task is suspended. Later, when the resource becomes “ready”, the task is awakened and retries the request. Therefore, the request was issued twice: the first time when a “busy” was received and a second time after the task was awakened. This means that this instruction used an execution slot in the processor.
If the resource is “ready” or if the resource has no indication, execution continues normally. Often the next instruction executed attempts to use the results requested from the resource. If the results are not yet ready, the task suspends. Again, this means that this instruction used an execution slot in the processor. When the results later arrive, the task awakes and re-executes the second statement a second time.
U.S. Pat. No. 6,330,584 to Joffe et al. (hereinafter the “Joffe et al.”) is incorporated by reference herein in its entirety. Joffe et al. describes a multi-tasking pipelined processor, in which “consecutive instructions are executed by different tasks, eliminating the need to purge an instruction execution pipeline of subsequent instructions when a previous instruction cannot be completed. The tasks do not share registers, which store task-specific values, thus eliminating the need to save or load registers when a new task is scheduled for execution. If an instruction accesses an unavailable resource, the instruction becomes suspended, allowing other tasks' instructions to be executed instead until the resource becomes available. Task scheduling is performed by hardware; no operating system is needed. Simple techniques are provided to synchronize shared resource access between different tasks.” (See Joffe et al., abstract.)
Joffe et al. further describes the “ready,” “active” and “suspend” task states and transitions among the states. (See Joffe et al., FIGS. 7–13B, and column 11, line 21 through column 17, line 61.)
The prior art discloses a method to suspend tasks, however, once the task is awakened from the suspension, the instruction during which the suspension occurred is re-executed a second time. Therefore, a more efficient way is needed to execute an instruction that leads to task suspension. Additionally, a more efficient way is needed to eliminate the re-execution of instructions after a suspended task awakens.